<template>
  <div id="AsnDetail">

    <div class="detail">
      <v-navMenu
        :detailNav="detailNav"
        :menuData="menuData"
        @setMentActive="setMentActive"
      ></v-navMenu>
      <component
        :inputData="{detailData,detailDataFpkw}"
        :is="currentComponent"
      ></component>
    </div>
  </div>
</template>

<script>
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "AsnDetail",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: false,
      fpkwFlag: true,
      selectData: {},
      detailData: {},
      detailDataFpkw: {},
      menuData: [
        { label: this.$t('config.general'), index: "1" },
        { label: this.$t('config.deliver'), index: "2" },
        { label: this.$t('config.propertyCode'), index: "3" },
        { label: this.$t('config.wgtData'), index: "4" },
        { label: this.$t('config.inbound'), index: "5" },
        { label: this.$t('config.outbound'), index: "6" },
        { label: this.$t('config.cyclecost'), index: "7" },
        { label: this.$t('config.rplotrule'), index: "9" },
        {label: this.$t('config.replace'), index: "11"}
      ],
      detailNav: "1",
      componentConfig: [
        {
          name: "RoutineDetails",
          label: this.$t('config.general'),
          component: () => import('./page/RoutineDetails.vue')
        },
        {
          name: "DeliverDetails",
          label: this.$t('config.deliver'),
          component: () => import('./page/DeliverDetails.vue')
        },
        {
          name: "PropertyCode",
          label: this.$t('config.propertyCode'),
          component: () => import('./page/PropertyCode.vue')
        },
        {
          name: "WgtDataDetails",
          label: this.$t('config.wgtData'),
          component: () => import('./page/WgtDataDetails.vue')
        },
        {
          name: "InboundDetails",
          label: this.$t('config.inbound'),
          component: () => import('./page/InboundDetails.vue')
        },
        {
          name: "OutboundDetails",
          label: this.$t('config.outbound'),
          component: () => import('./page/OutboundDetails.vue')
        },
        {
          name: "CyclecostDetalis",
          label: this.$t('config.cyclecost'),
          component: () => import('./page/CyclecostDetalis.vue')
        },
        {
          name: "SkuDetailReplenish",
          label: this.$t('config.allotLoc'),
          component: () => import('./page/SkuDetailReplenish.vue')
        },
        {
          name: "SkuDetailRplotrule",
          label: this.$t('config.rplotrule'),
          component: () => import('./page/SkuDetailRplotrule.vue')
        },
        {
          name: "fpkwDetail",
          label: this.$t('config.allotLocDetail'),
          component: () => import('./page/fpkwDetail.vue')
        },
        {
          name: "replace",
          label: this.$t('config.replace'),
          component: () => import('./page/replace.vue')
        },
        {
          name: "replaceDetail",
          label: this.$t('config.replaceDetail'),
          component: () => import('./page/replaceDetail.vue')
        },
      ],
      deleteStatus: true
    }
  },
  computed: {
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    pushMenu () {
      this.menuData.push({ label: this.$t('config.allotLoc'), index: "8" })
    },
    setMentActive (key) {
      this.detailNav = key;
    },
    async getData () {
      try {
        //let res = await this.$api.get(`/querySkuByName/${this.selectData.storerkey}/${this.selectData.sku}`);
        let res = await this.$api.post(`/querySkuByName`,{"storerkey":this.selectData.storerkey,"sku":this.selectData.sku});
        
          this.detailData = res.bean;
          //要重订购的数量
          if (!this.detailData.reorderqty) {
            this.$set(this.detailData, 'reorderqty', 0)
          }
          //订购成本
          if (!this.detailData.reorderpoint) {
            this.$set(this.detailData, 'reorderpoint', 0)
          }
        
      } catch (e) {
        this.$message.error(e);
      }
    },

  },
  mounted () {
    this.newFlag = this.$store.state.newFlag;
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.selectData = data.routeData;
      this.detailNav = data.detailNav;
    } else if (this.newFlag) {
      this.detailData = {
        storerkey: "",
        putawayzone: "RACK",
        putawayloc: "UNKNOWN",
        packkey: "STD",
        whseid: "USER",
        hazmatcodeskey: " ",
        itemreference: " ",
        descr: "",
        stdgrosswgt: 0,
        stdnetwgt: 0,
        stdcube: 0,
        tare: 0,
        class_: 34,
        class_name: "STD",
        scan_serial: "0",
        active: "1",
        skugroup: "STD",
        tariffkey: "XXXXXXXXXXX",
        lottable01label: "Lottable01",
        lottable02label: "Lottable02",
        lottable03label: "Lottable03",
        lottable04label: "Manufacturing Date",
        lottable05label: "Expiration Date",
        lottable06label: "Lottable06",
        lottable07label: "Lottable07",
        lottable08label: "Lottable08",
        lottable09label: "Lottable09",
        lottable10label: "Lottable10",
        qtylocationlimit: 0,
        qtylocationminimum: 0,
        strategykey: "STD",
        cartongroup: "STD",
        cube: 0,
        stdordercost: 0,
        carrycost: 0.00,
        price: 0.00,
        cost: 0.00,
        onreceiptcopypackkey: "0",
        rotateby: "lot",
        datecodedays: 999,
        defaultrotation: "1",
        shippablecontainer: "0",
        tareweight: 0.00,
        avgcaseweight: 0.00,
        tolerancepct: 0.00,
        shelflifeindicator: "0",
        shelflife: 0,
        icwflag: "0",
        icwby: "0",
        ideweight: "0",
        icdflag: "0",
        icdlabel1: " ",
        icdlabel2: " ",
        icdlabel3: " ",
        ocwflag: "0",
        ocwby: "0",
        odeweight: "1",
        oacoverride: "0",
        ocdflag: "0",
        ocdlabel1: " ",
        ocdlabel2: " ",
        ocdlabel3: " ",
        otareweight: 0,
        oavgcaseweight: 0,
        otolerancepct: 0,
        shelflifecodetype: "E",
        shelflifeonreceiving: 0,
        lottablevalidationkey: "STD",
        allowconsolidation: "0",
        minimumwaveqty: 0,
        bulkcartongroup: "STD",
        conveyable: "N",
        flowthruitem: "0",
        vert_Storage: "0",
        verifylot04lot05: "0",
        putawaystrategykey: "STD",
        receiptvalidationtemplate: "STD",
        stacklimit: "0",
        maxpalletsperzone: "0",
        ccdiscrepancyrule: "STD",
        qclocout: "PICKTO",
        ocdcatchwhen: "PICK",
        ocdcatchqty1: "0",
        ocdcatchqty2: "ANY",
        ocdcatchqty3: "ANY",
        lottable11label: "Delivery By Date",
        lottable12label: "Best By Date",
        toexpiredays: 0,
        todeliverbydays: 0,
        tobestbydays: 0,
        snum_Endtoend: 0,
        voicegroupingid: "0",
        dapicksort: "1",
        rplnsort: "1",
        stdnetwgt1: 0,
        cartonizeft: "0",
        fillqtyuom: " ",
        autoreleaselotby: "01",
        hourstoholdlot: 0,
        autoreleaselpnby: "01",
        hourstoholdlpn: 0,
        putawayclass: "0",
        groupfteach: "1",
        serialnumbe: "0",
        rtxlotturnoverrule: "1",
        rtxisexistscode: "1"
      }
    } else {
      this.selectData = this.$store.state.routeData;
      this.getData();
    }

  },
  watch: {

  },
  components: {
    "v-navMenu": navMenu,

  },
}
</script>

<style scoped>
</style>
